// Copyright (c) 2021 Presto Labs Pte. Ltd.
// Author: xguo

#include "coin2/exchange/base/log/proto_logger.h"

#include <iostream>
#include <string>

#include "coin2/exchange/base/log/order_logger.h"
#include "coin2/exchange/base/log/strategy_logger.h"

class PLogger : public BaseProtoLogger {
  using BaseProtoLogger::BaseProtoLogger;
  std::string GetEnsuredLogPath(int64_t) const override { return "/tmp/abc"; }
};

int main() {
  using OrderLogger = coin2::exchange::base::order_util::OrderLogger;
  using StrategyLogger = coin2::exchange::base::strategy_util::StrategyLogger;

  std::string root = "/tmp";
  std::string machine = "machine";
  int64_t ts = 123456789;
  coin::proto::AccountPosition pos;
  coin::proto::AccountBalance bal;

  PLogger logger(root, machine);

  logger.SetInitCallbackFunc([&logger](int64_t ts) {
      std::cout << "ts: " << ts << "\n";
      logger.Write("HELLOWORLD", true, ts);
  });
  logger.Write("helloworld", true, ts);

  coin::proto::AccountRequestProto request;
  request.set_owner("xguo");

  pos.set_exchange("Binance");
  pos.set_market_type("Futures");
  OrderLogger order_logger(request, root, machine);
  order_logger.WritePosition(pos, true, ts);

  pos.set_exchange("Okex");
  pos.set_market_type("Spot");
  order_logger.WritePosition(pos, true, ts);

  coin::proto::StrategyRequestProto strat_request;
  strat_request.set_strategy_name("stratname");
  bal.set_exchange("Binance");
  StrategyLogger strat_logger(strat_request, root, machine);
  strat_logger.WriteReserve(bal, true, ts);

  return 0;
}
